import { Root } from '@/types'
import { createSlice } from '@reduxjs/toolkit'

export type UserState = {
  menuList: Root
  id: string
}

const initialState = {
  menuList: [],
  id: ''
}

const userStore = createSlice({
  name: 'user',
  initialState,
  reducers: {
    setMenuList(state, action) {
      state.menuList = action.payload
    },
    setId(state, action) {
      state.id = action.payload
    }
  }
})

export const { setId, setMenuList } = userStore.actions
const useUserStore = userStore.reducer

export default useUserStore
